package com.ln.yygh.hosp.controller.api;

import com.ln.yygh.common.result.Result;
import com.ln.yygh.hosp.service.*;
import com.ln.yygh.model.hosp.Hospital;
import com.ln.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.*;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lianXiaoChen
 * @create: 2021-06-04 21:00
 */
@RestController
@RequestMapping("/api/hosp/hospital")
@Api("前端列表展示")
public class HospApiController {
    @Autowired
    private Hospitalervice hospitalervice;
    @Autowired
    private DepartmentService departmentService;
    @ApiOperation("列表展示（条件+分页）")
    @GetMapping("findHospList/{page}/{limit}")
    public Result findHospList(@PathVariable Integer page,
                               @PathVariable Integer limit,
                               HospitalQueryVo hospitalQueryVo){
        Page<Hospital> hospital = hospitalervice.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(hospital);
    }
    @ApiOperation("根据医院名称模糊查询")
    @GetMapping("findByHosname/{hosname}")
    public Result findByHosname(@PathVariable String hosname){
        List<Hospital> list = hospitalervice.findByHosName(hosname);
        return Result.ok(list);
    }

    @ApiOperation(value = "根据医院编号获取科室信息")
    @GetMapping("department/{hoscode}")
    public Result department(@PathVariable String hoscode){
        return Result.ok(departmentService.findDeptTree(hoscode));
    }

    @ApiOperation(value = "医院预约挂号详情")
    @GetMapping("findHospDetail/{hoscode}")
    public Result item( @PathVariable String hoscode){
        return Result.ok(hospitalervice.item(hoscode));
    }

}
